package com.yxb.news.service.impl;

import java.util.List;
import com.yxb.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yxb.news.mapper.TeachingNewsMapper;
import com.yxb.news.domain.TeachingNews;
import com.yxb.news.service.ITeachingNewsService;

import static com.yxb.common.utils.SecurityUtils.getLoginUser;

/**
 * 家教资讯Service业务层处理
 * 
 * @author 林德炫
 * @date 2025-03-04
 */
@Service
public class TeachingNewsServiceImpl implements ITeachingNewsService 
{
    @Autowired
    private TeachingNewsMapper teachingNewsMapper;

    /**
     * 查询家教资讯
     * 
     * @param newsId 家教资讯主键
     * @return 家教资讯
     */
    @Override
    public TeachingNews selectTeachingNewsByNewsId(Long newsId)
    {
        return teachingNewsMapper.selectTeachingNewsByNewsId(newsId);
    }

    /**
     * 查询家教资讯列表
     * 
     * @param teachingNews 家教资讯
     * @return 家教资讯
     */
    @Override
    public List<TeachingNews> selectTeachingNewsList(TeachingNews teachingNews)
    {
        return teachingNewsMapper.selectTeachingNewsList(teachingNews);
    }

    /**
     * 新增家教资讯
     * 
     * @param teachingNews 家教资讯
     * @return 结果
     */
    @Override
    public int insertTeachingNews(TeachingNews teachingNews)
    {
        teachingNews.setAuthorId(getLoginUser().getUserId());
        teachingNews.setCreateTime(DateUtils.getNowDate());
        return teachingNewsMapper.insertTeachingNews(teachingNews);
    }

    /**
     * 修改家教资讯
     * 
     * @param teachingNews 家教资讯
     * @return 结果
     */
    @Override
    public int updateTeachingNews(TeachingNews teachingNews)
    {
        return teachingNewsMapper.updateTeachingNews(teachingNews);
    }

    /**
     * 批量删除家教资讯
     * 
     * @param newsIds 需要删除的家教资讯主键
     * @return 结果
     */
    @Override
    public int deleteTeachingNewsByNewsIds(Long[] newsIds)
    {
        return teachingNewsMapper.deleteTeachingNewsByNewsIds(newsIds);
    }

    /**
     * 删除家教资讯信息
     * 
     * @param newsId 家教资讯主键
     * @return 结果
     */
    @Override
    public int deleteTeachingNewsByNewsId(Long newsId)
    {
        return teachingNewsMapper.deleteTeachingNewsByNewsId(newsId);
    }
}
